<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets<f:view>
            <h:form>
                <h1><h:outputText value="List"/></h1>
                <p:dataTable value="#{customerMBean.customers}" var="item" 
             emptyMessage="No customer found with given criteria" 
             widgetVar="customerTable"
             
             paginator="true"
             rows="10">
                    <f:facet name="header">    
                    <p:outputPanel>    
                        <h:outputText value="Search all fields:" />    
                        <p:inputText id="globalFilter" onkeyup="customerTable.filter()" style="width:150px" />    
                    </p:outputPanel>    
                </f:facet> 
                    <p:column headerText="CustomerId"  
                    sortBy="#{item.customerId}"  
                    filterBy="#{item.customerId}"  
                    filterMatchMode="contains">  
                    <h:commandLink action="#{customerMBean.showDetails(item)}" value="#{item.customerId}"/>    
                    </p:column> 
                  
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Name"/>
                        </f:facet>
                        <h:outputText value="#{item.name}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Addressline1"/>
                        </f:facet>
                        <h:outputText value="#{item.addressline1}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Addressline2"/>
                        </f:facet>
                        <h:outputText value="#{item.addressline2}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="City"/>
                        </f:facet>
                        <h:outputText value="#{item.city}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="State"/>
                        </f:facet>
                        <h:outputText value="#{item.state}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Phone"/>
                        </f:facet>
                        <h:outputText value="#{item.phone}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Fax"/>
                        </f:facet>
                        <h:outputText value="#{item.fax}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Email"/>
                        </f:facet>
                        <h:outputText value="#{item.email}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="CreditLimit"/>
                        </f:facet>
                        <h:outputText value="#{item.creditLimit}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Zip"/>
                        </f:facet>
                        <h:outputText value="#{item.zip}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="DiscountCode"/>
                        </f:facet>
                        <h:outputText value="#{item.discountCode.discountCode} : #{item.discountCode.rate}%" />  
                    </p:column>
                </p:dataTable>
            </h:form>
        </f:view>

    </h:body>
</html>

